
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>ST_Distance · PostGIS中文指南</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="xxx">
        
        
    
    <link rel="stylesheet" href="../../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-pageview-count/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-prism/prism-okaidia.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-emphasize/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-search-pro/search.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-splitter/splitter.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-folding-chapters/folding-chapters.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="ST_Project.html" />
    
    
    <link rel="prev" href="ST_ClosestPoint.html" />
    

    <script src="../../gitbook/gitbook-plugin-graph/d3.min.js"></script>
    <script src="../../gitbook/gitbook-plugin-graph/function-plot.js"></script>    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        <li class="header">第 Ⅰ 部分：PostGIS基础</li>
        
        
    
        <li class="chapter " data-level="1.1" data-path="../../">
            
                <a href="../../">
            
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" >
            
                <span>
            
                    
                    一 初识PostGIS
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../../introduction/PostgisAbility.html">
            
                <a href="../../introduction/PostgisAbility.html">
            
                    
                    1.1 PostGIS特性
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="../../introduction/PostgisAbility.html">
            
                <a href="../../introduction/PostgisAbility.html">
            
                    
                    1.2 PostGIS使用场景
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.2.1" data-path="../../installation/PostgreSQL Installation.html">
            
                <a href="../../installation/PostgreSQL Installation.html">
            
                    
                    1.2.1 适用场景
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2.2" data-path="../../installation/PostGIS Installation.html">
            
                <a href="../../installation/PostGIS Installation.html">
            
                    
                    1.2.2 不适用场景
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.2.3" data-path="../../introduction/PostgisAbility.html">
            
                <a href="../../introduction/PostgisAbility.html">
            
                    
                    1.3 PostGIS使用建议
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.4" >
            
                <span>
            
                    
                    1.4 PostGIS安装
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.4.1" data-path="../../installation/PostgreSQL Installation.html">
            
                <a href="../../installation/PostgreSQL Installation.html">
            
                    
                    1.4.1 PostgreSQL安装
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.4.2" data-path="../../installation/PostGIS Installation.html">
            
                <a href="../../installation/PostGIS Installation.html">
            
                    
                    1.4.2 PostGIS安装
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.2.5" data-path="../../introduction/ReleaseNotes.html">
            
                <a href="../../introduction/ReleaseNotes.html">
            
                    
                    1.5 PostGIS重大版本
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" >
            
                <span>
            
                    
                    二 PostGIS入门
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" >
            
                <span>
            
                    
                    2.1 客户端介绍
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1.1" >
            
                <span>
            
                    
                    2.1.1 psql
            
                </span>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.1.2" >
            
                <span>
            
                    
                    2.1.2 qgis
            
                </span>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3.2" >
            
                <span>
            
                    
                    2.2 空间数据库
            
                </span>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" >
            
                <span>
            
                    
                    2.3 数据导入
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.3.1" >
            
                <span>
            
                    
                    2.3.1 shp
            
                </span>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3.2" >
            
                <span>
            
                    
                    2.3.2 csv
            
                </span>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3.3" >
            
                <span>
            
                    
                    2.3.3 excel
            
                </span>
            

            
        </li>
    

            </ul>
            
        </li>
    

            </ul>
            
        </li>
    

    
        
        <li class="header">第 Ⅱ 部分：API手册</li>
        
        
    
        <li class="chapter " data-level="2.1" >
            
                <span>
            
                    
                    八 矢量函数
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.1.1" >
            
                <span>
            
                    
                    8.2 空间表管理
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.1.1.1" data-path="../TableManager/AddGeometryColumn.html">
            
                <a href="../TableManager/AddGeometryColumn.html">
            
                    
                    8.2.1 AddGeometryColumn
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.1.2" data-path="../TableManager/DropGeometryColumn.html">
            
                <a href="../TableManager/DropGeometryColumn.html">
            
                    
                    8.2.2 DropGeometryColumn
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.1.3" data-path="../TableManager/DropGeometryTable.html">
            
                <a href="../TableManager/DropGeometryTable.html">
            
                    
                    8.2.3 DropGeometryTable
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.1.4" data-path="../TableManager/Find_SRID.html">
            
                <a href="../TableManager/Find_SRID.html">
            
                    
                    8.2.4 Find_SRID
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.1.5" data-path="../TableManager/Populate_Geometry_Columns.html">
            
                <a href="../TableManager/Populate_Geometry_Columns.html">
            
                    
                    8.2.5 Populate_Geometry_Columns
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.1.6" data-path="../TableManager/UpdateGeometrySRID.html">
            
                <a href="../TableManager/UpdateGeometrySRID.html">
            
                    
                    8.2.6 UpdateGeometrySRID
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.1.2" >
            
                <span>
            
                    
                    8.4 元数据读写
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.1.2.1" data-path="../Accessors.html">
            
                <a href="../Accessors.html#GeometryType">
            
                    
                    GeometryType
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.2.2" data-path="../Accessors.html">
            
                <a href="../Accessors.html#ST_GeometryType">
            
                    
                    ST_GeometryType
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.2.3" data-path="../Accessors.html">
            
                <a href="../Accessors.html#ST_CoordDim">
            
                    
                    ST_CoordDim与ST_NDims
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.2.4" data-path="../Accessors.html">
            
                <a href="../Accessors.html#ST_Dimension">
            
                    
                    ST_Dimension
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.2.5" data-path="../Accessors.html">
            
                <a href="../Accessors.html#ST_Zmflag">
            
                    
                    ST_Zmflag
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.2.6" data-path="../Accessors.html">
            
                <a href="../Accessors.html#ST_HasArc">
            
                    
                    ST_HasArc
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.2.7" data-path="../Accessors.html">
            
                <a href="../Accessors.html#ST_IsPolygonCCW">
            
                    
                    ST_IsPolygonCCW
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.2.8" data-path="../Accessors.html">
            
                <a href="../Accessors.html#ST_IsPolygonCW">
            
                    
                    ST_IsPolygonCW
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.2.9" data-path="../Accessors.html">
            
                <a href="../Accessors.html#ST_IsClosed">
            
                    
                    ST_IsClosed
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.2.10" data-path="../Accessors.html">
            
                <a href="../Accessors.html#ST_IsCollection">
            
                    
                    ST_IsCollection
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.2.11" data-path="../Accessors.html">
            
                <a href="../Accessors.html#ST_IsEmpty">
            
                    
                    ST_IsEmpty
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.2.12" data-path="../Accessors.html">
            
                <a href="../Accessors.html#ST_IsRing">
            
                    
                    ST_IsRing
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.2.13" data-path="../Accessors.html">
            
                <a href="../Accessors.html#ST_IsSimple">
            
                    
                    ST_IsSimple
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.2.14" data-path="../Accessors.html">
            
                <a href="../Accessors.html#ST_Boundary">
            
                    
                    ST_Boundary
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.2.15" data-path="../Accessors.html">
            
                <a href="../Accessors.html#ST_Envelope">
            
                    
                    ST_Envelope
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.2.16" data-path="../Accessors.html">
            
                <a href="../Accessors.html#ST_BoundingDiagonal">
            
                    
                    ST_BoundingDiagonal
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.2.17" data-path="../Accessors.html">
            
                <a href="../Accessors.html#ST_X">
            
                    
                    ST_X,ST_Y,ST_Z,ST_M
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.2.18" data-path="../Accessors.html">
            
                <a href="../Accessors.html#ST_StartPoint">
            
                    
                    ST_StartPoint,ST_EndPoint
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.2.19" data-path="../Accessors.html">
            
                <a href="../Accessors.html#ST_NumGeometries">
            
                    
                    ST_NumGeometries,ST_GeometryN
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.2.20" data-path="../Accessors.html">
            
                <a href="../Accessors.html#ST_NRings">
            
                    
                    ST_NRings,ST_ExteriorRing,ST_NumInteriorRings,ST_NumInteriorRing,ST_InteriorRingN
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.2.21" data-path="../Accessors.html">
            
                <a href="../Accessors.html#ST_NumPatches">
            
                    
                    ST_NumPatches,ST_PatchN
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.2.22" data-path="../Accessors.html">
            
                <a href="../Accessors.html#ST_NPoints">
            
                    
                    ST_NPoints,ST_NumPoints,ST_PointN,ST_Points
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.2.23" data-path="../Accessors.html">
            
                <a href="../Accessors.html#ST_MemSize">
            
                    
                    ST_MemSize
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.2.24" data-path="../Accessors.html">
            
                <a href="../Accessors.html#ST_Summary">
            
                    
                    ST_Summary
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.2.25" data-path="../Accessors.html">
            
                <a href="../Accessors.html#ST_Dump">
            
                    
                    ST_Dump,ST_DumpPoints,ST_DumpRings
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.1.3" >
            
                <span>
            
                    
                    8.11 空间关系
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.1.3.1" data-path="../SpatialRelationships.html">
            
                <a href="../SpatialRelationships.html#ST_Intersects">
            
                    
                    ST_Intersects
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.3.2" data-path="../SpatialRelationships.html">
            
                <a href="../SpatialRelationships.html#ST_Intersects">
            
                    
                    ST_Disjoint
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.3.3" data-path="../SpatialRelationships.html">
            
                <a href="../SpatialRelationships.html#ST_Contains">
            
                    
                    ST_Contains
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.3.4" data-path="../SpatialRelationships.html">
            
                <a href="../SpatialRelationships.html#ST_Contains">
            
                    
                    ST_Within
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.3.5" data-path="../SpatialRelationships.html">
            
                <a href="../SpatialRelationships.html#ST_Equals">
            
                    
                    ST_Equals
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.3.6" data-path="../SpatialRelationships.html">
            
                <a href="../SpatialRelationships.html#ST_ContainsProperly">
            
                    
                    ST_ContainsProperly
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.3.7" data-path="../SpatialRelationships.html">
            
                <a href="../SpatialRelationships.html#ST_Covers">
            
                    
                    ST_Covers
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.3.8" data-path="../SpatialRelationships.html">
            
                <a href="../SpatialRelationships.html#ST_Covers">
            
                    
                    ST_CoveredBy
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.3.9" data-path="../SpatialRelationships.html">
            
                <a href="../SpatialRelationships.html#ST_Overlaps">
            
                    
                    ST_Overlaps
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.3.10" data-path="../SpatialRelationships.html">
            
                <a href="../SpatialRelationships.html#ST_Overlaps">
            
                    
                    ST_Crosses
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.3.11" data-path="../SpatialRelationships.html">
            
                <a href="../SpatialRelationships.html#ST_Touches">
            
                    
                    ST_Touches
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.3.12" data-path="../SpatialRelationships.html">
            
                <a href="../SpatialRelationships.html#ST_Relate">
            
                    
                    ST_Relate
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.3.13" data-path="../SpatialRelationships.html">
            
                <a href="../SpatialRelationships.html#ST_RelateMatch">
            
                    
                    ST_RelateMatch
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.1.4" >
            
                <span>
            
                    
                    8.12 空间测量
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.1.4.1" data-path="ST_3DClosestPoint.html">
            
                <a href="ST_3DClosestPoint.html#ST_3DClosestPoint">
            
                    
                    ST_3DClosestPoint
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.4.2" data-path="ST_3DDistance.html">
            
                <a href="ST_3DDistance.html">
            
                    
                    ST_3DDistance
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.4.3" data-path="ST_Angle.html">
            
                <a href="ST_Angle.html">
            
                    
                    ST_Angle
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.4.4" data-path="ST_Area.html">
            
                <a href="ST_Area.html">
            
                    
                    ST_Area
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.4.5" data-path="ST_Azimuth.html">
            
                <a href="ST_Azimuth.html">
            
                    
                    ST_Azimuth
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.4.6" data-path="ST_ClosestPoint.html">
            
                <a href="ST_ClosestPoint.html">
            
                    
                    ST_ClosestPoint
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="2.1.4.7" data-path="ST_Distance.html">
            
                <a href="ST_Distance.html">
            
                    
                    ST_Distance
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.4.8" data-path="ST_Project.html">
            
                <a href="ST_Project.html">
            
                    
                    ST_Project
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.1.5" >
            
                <span>
            
                    
                    8.14 仿射变换
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.1.5.1" data-path="../AffineTransformations/ST_Affine.html">
            
                <a href="../AffineTransformations/ST_Affine.html#ST_Affine">
            
                    
                    ST_Affine
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.5.2" data-path="../AffineTransformations/ST_Rotate.html">
            
                <a href="../AffineTransformations/ST_Rotate.html">
            
                    
                    ST_Rotate
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.5.3" data-path="../AffineTransformations/ST_RotateX.html">
            
                <a href="../AffineTransformations/ST_RotateX.html">
            
                    
                    ST_RotateX
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.5.4" data-path="../AffineTransformations/ST_RotateY.html">
            
                <a href="../AffineTransformations/ST_RotateY.html">
            
                    
                    ST_RotateY
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.5.5" data-path="../AffineTransformations/ST_RotateZ.html">
            
                <a href="../AffineTransformations/ST_RotateZ.html">
            
                    
                    ST_RotateZ
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.5.6" data-path="../AffineTransformations/ST_Scale.html">
            
                <a href="../AffineTransformations/ST_Scale.html">
            
                    
                    ST_Scale
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.5.7" data-path="../AffineTransformations/ST_Translate.html">
            
                <a href="../AffineTransformations/ST_Translate.html">
            
                    
                    ST_Translate
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.5.8" data-path="../AffineTransformations/ST_TransScale.html">
            
                <a href="../AffineTransformations/ST_TransScale.html">
            
                    
                    ST_TransScale
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.1.6" >
            
                <span>
            
                    
                    8.15 空间聚类
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.1.6.1" data-path="../Clustering.html">
            
                <a href="../Clustering.html#ST_ClusterDBSCAN">
            
                    
                    ST_ClusterDBSCAN
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.6.2" data-path="../Clustering.html">
            
                <a href="../Clustering.html#ST_ClusterIntersecting">
            
                    
                    ST_ClusterIntersecting
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.6.3" data-path="../Clustering.html">
            
                <a href="../Clustering.html#ST_ClusterKMeans">
            
                    
                    ST_ClusterKMeans
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.6.4" data-path="../Clustering.html">
            
                <a href="../Clustering.html#ST_ClusterWithin">
            
                    
                    ST_ClusterWithin
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.1.7" >
            
                <span>
            
                    
                    8.16 线性参考
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.1.7.1" data-path="../LinearReferencing/ST_LineInterpolatePoint.html">
            
                <a href="../LinearReferencing/ST_LineInterpolatePoint.html">
            
                    
                    ST_LineInterpolatePoint
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.7.2" data-path="../LinearReferencing/ST_3dLineInterpolatePoint.html">
            
                <a href="../LinearReferencing/ST_3dLineInterpolatePoint.html">
            
                    
                    ST_3dLineInterpolatePoint
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.7.3" data-path="../LinearReferencing/ST_LineInterpolatePoints.html">
            
                <a href="../LinearReferencing/ST_LineInterpolatePoints.html">
            
                    
                    ST_LineInterpolatePoints
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.7.4" data-path="../LinearReferencing/ST_LineLocatePoint.html">
            
                <a href="../LinearReferencing/ST_LineLocatePoint.html">
            
                    
                    ST_LineLocatePoint
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.7.5" data-path="../LinearReferencing/ST_LineSubstring.html">
            
                <a href="../LinearReferencing/ST_LineSubstring.html">
            
                    
                    ST_LineSubstring
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.7.6" data-path="../LinearReferencing/ST_LocateAlong.html">
            
                <a href="../LinearReferencing/ST_LocateAlong.html">
            
                    
                    ST_LocateAlong
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.7.7" data-path="../LinearReferencing/ST_LocateBetween.html">
            
                <a href="../LinearReferencing/ST_LocateBetween.html">
            
                    
                    ST_LocateBetween
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.7.8" data-path="../LinearReferencing/ST_LocateBetweenElevations.html">
            
                <a href="../LinearReferencing/ST_LocateBetweenElevations.html">
            
                    
                    ST_LocateBetweenElevations
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.7.9" data-path="../LinearReferencing/ST_InterpolatePoint.html">
            
                <a href="../LinearReferencing/ST_InterpolatePoint.html">
            
                    
                    ST_InterpolatePoint
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.7.10" data-path="../LinearReferencing/ST_AddMeasure.html">
            
                <a href="../LinearReferencing/ST_AddMeasure.html">
            
                    
                    ST_AddMeasure
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.7.11" data-path="../LinearReferencing/examples.html">
            
                <a href="../LinearReferencing/examples.html">
            
                    
                    综合案例
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

            </ul>
            
        </li>
    

    
        
        <li class="header">第 Ⅲ 部分：PostGIS++</li>
        
        
    

    
        
        <li class="header">第 Ⅳ 部分：常见问题</li>
        
        
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../.." >ST_Distance</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h2 id="stdistance">ST_Distance</h2>
<h3 id="&#x4E00;&#x3001;-&#x65B9;&#x6CD5;&#x529F;&#x80FD;&#x63CF;&#x8FF0;">&#x4E00;&#x3001; &#x65B9;&#x6CD5;&#x529F;&#x80FD;&#x63CF;&#x8FF0;</h3>
<p>&#x5BF9;&#x4E8E;&#x51E0;&#x4F55;&#x7C7B;&#x578B;&#xFF0C;&#x4EE5;&#x6295;&#x5F71;&#x5355;&#x4F4D;&#xFF08;&#x7A7A;&#x95F4;&#x53C2;&#x8003;&#x5355;&#x4F4D;&#xFF09;&#x8FD4;&#x56DE;&#x4E24;&#x4E2A;&#x51E0;&#x4F55;&#x4E4B;&#x95F4;&#x7684;&#x6700;&#x5C0F;&#x4E8C;&#x7EF4;&#x7B1B;&#x5361;&#x5C14;&#xFF08;&#x5E73;&#x9762;&#xFF09;&#x8DDD;&#x79BB;&#x3002;</p>
<p>&#x5BF9;&#x4E8E;&#x5730;&#x7406;&#x7C7B;&#x578B;&#xFF0C;&#x9ED8;&#x8BA4;&#x60C5;&#x51B5;&#x4E0B;&#x8FD4;&#x56DE;&#x4E24;&#x4E2A;&#x5730;&#x7406;&#x5BF9;&#x8C61;&#x4E4B;&#x95F4;&#x7684;&#x6700;&#x5C0F;&#x6D4B;&#x5730;&#x8DDD;&#x79BB;&#xFF08;&#x4EE5;&#x7C73;&#x4E3A;&#x5355;&#x4F4D;&#xFF09;&#xFF0C;&#x8BF7;&#x8BA1;&#x7B97;&#x7531;SRID&#x786E;&#x5B9A;&#x7684;&#x692D;&#x7403;&#x4F53;&#x3002;&#x5982;&#x679C;use_spheroid&#x4E3A;false&#xFF0C;&#x5219;&#x4F7F;&#x7528;&#x66F4;&#x5FEB;&#x7684;&#x7403;&#x9762;&#x8BA1;&#x7B97;&#x3002;</p>
<h3 id="&#x4E8C;&#x3001;&#x7528;&#x6CD5;">&#x4E8C;&#x3001;&#x7528;&#x6CD5;</h3>
<pre class="language-"><code>float ST_Distance(geometry g1, geometry g2);
float ST_Distance(geography geog1, geography geog2, &gt;boolean use_spheroid=true);
</code></pre><h3 id="&#x4E09;&#x3001;&#x5E94;&#x7528;&#x793A;&#x4F8B;">&#x4E09;&#x3001;&#x5E94;&#x7528;&#x793A;&#x4F8B;</h3>
<blockquote>
<p>&#x8BE5;&#x65B9;&#x6CD5;&#x5F97;&#x4F7F;&#x7528;&#x793A;&#x4F8B;&#xFF0C;&#x6253;&#x7B97;&#x5168;&#x90E8;&#x7528;&#x5B98;&#x7F51;&#x5F97;&#x793A;&#x4F8B;&#xFF0C;&#x56E0;&#x4E3A;&#x5B98;&#x7F51;&#x5F97;&#x4F7F;&#x7528;&#x793A;&#x4F8B;&#x5199;&#x4E2A;&#x8DB3;&#x591F;&#x8BE6;&#x7EC6;&#x3002;</p>
<h6 id="1-&#x51E0;&#x4F55;&#x793A;&#x4F8B;-&#x5E73;&#x9762;&#x5EA6;&#x4E3A;4326&#x7684;&#x5355;&#x4F4D;&#x4E3A;wgs-84&#x957F;&#x7EAC;&#x5EA6;&#xFF0C;&#x5355;&#x4F4D;&#x4E3A;&#x5EA6;&#x3002;">1 &#x51E0;&#x4F55;&#x793A;&#x4F8B;-&#x5E73;&#x9762;&#x5EA6;&#x4E3A;4326&#x7684;&#x5355;&#x4F4D;&#x4E3A;WGS 84&#x957F;&#x7EAC;&#x5EA6;&#xFF0C;&#x5355;&#x4F4D;&#x4E3A;&#x5EA6;&#x3002;</h6>
</blockquote>
<pre class="language-"><code>SELECT ST_Distance&#xFF08;
        &apos;SRID = 4326; POINT&#xFF08;-72.1235 42.3521&#xFF09;&apos;:: geometry&#xFF0C;
        &apos;SRID = 4326; LINESTRING&#xFF08;-72.1260 42.45&#xFF0C;-72.123 42.1546&#xFF09;&apos;:: geometry 
    &#xFF09;; 
st_distance 
----------------- 
0.00150567726382282
</code></pre><h6 id="2-&#x51E0;&#x4F55;&#x793A;&#x4F8B;-&#x5355;&#x4F4D;&#x4E3A;&#x7C73;&#xFF08;srid&#xFF1A;3857&#xFF0C;&#x4E0E;&#x6D41;&#x884C;&#x7684;&#x7F51;&#x7EDC;&#x5730;&#x56FE;&#x4E0A;&#x7684;&#x50CF;&#x7D20;&#x6210;&#x6BD4;&#x4F8B;&#xFF09;">2 &#x51E0;&#x4F55;&#x793A;&#x4F8B;-&#x5355;&#x4F4D;&#x4E3A;&#x7C73;&#xFF08;SRID&#xFF1A;3857&#xFF0C;&#x4E0E;&#x6D41;&#x884C;&#x7684;&#x7F51;&#x7EDC;&#x5730;&#x56FE;&#x4E0A;&#x7684;&#x50CF;&#x7D20;&#x6210;&#x6BD4;&#x4F8B;&#xFF09;</h6>
<blockquote>
<p>&#x5C3D;&#x7BA1;&#x8BE5;&#x503C;&#x4E0D;&#x53EF;&#x7528;&#xFF0C;&#x4F46;&#x53EF;&#x4EE5;&#x6B63;&#x786E;&#x6BD4;&#x8F83;&#x9644;&#x8FD1;&#x7684;&#x503C;&#xFF0C;&#x8FD9;&#x4F7F;&#x5176;&#x6210;&#x4E3A;KNN&#x6216;KMeans&#x7B49;&#x7B97;&#x6CD5;&#x7684;&#x4E0D;&#x9519;&#x9009;&#x62E9;&#x3002;</p>
</blockquote>
<pre class="language-"><code>SELECT ST_Distance&#xFF08;
            ST_Transform&#xFF08;&apos;SRID = 4326; POINT&#xFF08;-72.1235 42.3521&#xFF09;&apos;:: geometry&#xFF0C;3857&#xFF09;&#xFF0C;
            ST_Transform&#xFF08;&apos;SRID = 4326; LINESTRING&#xFF08;-72.1260 42.45&#xFF0C;-72.123 42.1546&#xFF09;&apos;:: geometry&#xFF0C;3857&#xFF09;
        &#xFF09;; 
st_distance 
----------------- 
167.441410065196
</code></pre><h6 id="3-&#x51E0;&#x4F55;&#x793A;&#x4F8B;-&#x4EE5;&#x7C73;&#x4E3A;&#x5355;&#x4F4D;&#xFF08;srid&#xFF1A;&#x5982;&#x4E0A;&#x6240;&#x8FF0;&#x4E3A;3857&#xFF0C;&#x4F46;&#x901A;&#x8FC7;cos&#xFF08;lat&#xFF09;&#x8FDB;&#x884C;&#x4E86;&#x6821;&#x6B63;&#x4EE5;&#x89E3;&#x51B3;&#x53D8;&#x5F62;&#xFF09;">3 &#x51E0;&#x4F55;&#x793A;&#x4F8B;-&#x4EE5;&#x7C73;&#x4E3A;&#x5355;&#x4F4D;&#xFF08;SRID&#xFF1A;&#x5982;&#x4E0A;&#x6240;&#x8FF0;&#x4E3A;3857&#xFF0C;&#x4F46;&#x901A;&#x8FC7;cos&#xFF08;lat&#xFF09;&#x8FDB;&#x884C;&#x4E86;&#x6821;&#x6B63;&#x4EE5;&#x89E3;&#x51B3;&#x53D8;&#x5F62;&#xFF09;</h6>
<pre class="language-"><code>SELECT ST_Distance&#xFF08;
            ST_Transform&#xFF08;&apos;SRID = 4326; POINT&#xFF08;-72.1235 42.3521&#xFF09;&apos;:: geometry&#xFF0C;3857&#xFF09;&#xFF0C;
            ST_Transform&#xFF08;&apos;SRID = 4326; LINESTRING&#xFF08;-72.1260 42.45&#xFF0C;-72.123 42.1546&#xFF09;&apos;:: geometry&#xFF0C;3857&#xFF09;
        &#xFF09;* cosd&#xFF08;42.3521&#xFF09;; 
st_distance 
----------------- 
123.742351254151
</code></pre><h6 id="4-&#x51E0;&#x4F55;&#x793A;&#x4F8B;-&#x5355;&#x4F4D;&#x4E3A;&#x7C73;&#xFF08;srid&#xFF1A;26986&#xFF09;&#xFF08;&#x5BF9;&#x9A6C;&#x8428;&#x8BF8;&#x585E;&#x5DDE;&#x6700;&#x4E3A;&#x51C6;&#x786E;&#xFF09;">4 &#x51E0;&#x4F55;&#x793A;&#x4F8B;-&#x5355;&#x4F4D;&#x4E3A;&#x7C73;&#xFF08;SRID&#xFF1A;26986&#xFF09;&#xFF08;&#x5BF9;&#x9A6C;&#x8428;&#x8BF8;&#x585E;&#x5DDE;&#x6700;&#x4E3A;&#x51C6;&#x786E;&#xFF09;</h6>
<pre class="language-"><code>SELECT ST_Distance&#xFF08;
            ST_Transform&#xFF08;&apos;SRID = 4326; POINT&#xFF08;-72.1235 42.3521&#xFF09;&apos;:: geometry&#xFF0C;26986&#xFF09;&#xFF0C;
            ST_Transform&#xFF08;&apos;SRID = 4326; LINESTRING&#xFF08;-72.1260 42.45&#xFF0C;-72.123 42.1546&#xFF09;&apos;:: geometry&#xFF0C;26986&#xFF09;
        &#xFF09;; 
st_distance 
----------------- 
123.797937878454
</code></pre><h6 id="5-&#x51E0;&#x4F55;&#x793A;&#x4F8B;-&#x5355;&#x4F4D;&#x4E3A;&#x7C73;&#xFF08;srid&#xFF1A;2163&#x7F8E;&#x56FD;&#x56FD;&#x5BB6;&#x5730;&#x56FE;&#x96C6;&#x76F8;&#x7B49;&#x533A;&#x57DF;&#xFF09;&#xFF08;&#x6700;&#x4E0D;&#x51C6;&#x786E;&#xFF09;">5 &#x51E0;&#x4F55;&#x793A;&#x4F8B;-&#x5355;&#x4F4D;&#x4E3A;&#x7C73;&#xFF08;SRID&#xFF1A;2163&#x7F8E;&#x56FD;&#x56FD;&#x5BB6;&#x5730;&#x56FE;&#x96C6;&#x76F8;&#x7B49;&#x533A;&#x57DF;&#xFF09;&#xFF08;&#x6700;&#x4E0D;&#x51C6;&#x786E;&#xFF09;</h6>
<pre class="language-"><code>SELECT ST_Distance&#xFF08;
            ST_Transform&#xFF08;&apos;SRID = 4326; POINT&#xFF08;-72.1235 42.3521&#xFF09;&apos;:: geometry&#xFF0C;2163&#xFF09;&#xFF0C;
            ST_Transform&#xFF08;&apos;SRID = 4326; LINESTRING&#xFF08;-72.1260 42.45&#xFF0C;-72.123 42.1546&#xFF09;&apos;:: geometry&#xFF0C;2163&#xFF09;
        &#xFF09;; 

st_distance 
------------------ 
126.664256056812
</code></pre><h6 id="6-geography-&#x8F93;&#x5165;&#x8BA1;&#x7B97;&#xFF0C;&#x4F46;&#x4EE5;&#x7C73;&#x4E3A;&#x5355;&#x4F4D;&#x8FDB;&#x884C;&#x6CE8;&#x91CA;-&#x4F7F;&#x7528;&#x7403;&#x4F53;&#x53EF;&#x52A0;&#x5FEB;&#x8BA1;&#x7B97;&#x901F;&#x5EA6;&#x5E76;&#x964D;&#x4F4E;&#x51C6;&#x786E;&#x5EA6;&#x3002;">6 geography &#x8F93;&#x5165;&#x8BA1;&#x7B97;&#xFF0C;&#x4F46;&#x4EE5;&#x7C73;&#x4E3A;&#x5355;&#x4F4D;&#x8FDB;&#x884C;&#x6CE8;&#x91CA;-&#x4F7F;&#x7528;&#x7403;&#x4F53;&#x53EF;&#x52A0;&#x5FEB;&#x8BA1;&#x7B97;&#x901F;&#x5EA6;&#x5E76;&#x964D;&#x4F4E;&#x51C6;&#x786E;&#x5EA6;&#x3002;</h6>
<pre class="language-"><code>SELECT ST_Distance(gg1, gg2) As spheroid_dist, ST_Distance(gg1, gg2, false) As sphere_dist
FROM (SELECT
    &apos;SRID=4326;POINT(-72.1235 42.3521)&apos;::geography as gg1,
    &apos;SRID=4326;LINESTRING(-72.1260 42.45, -72.123 42.1546)&apos;::geography as gg2
    ) As foo  ;

  spheroid_dist   |   sphere_dist
------------------+------------------
 123.802076746848 | 123.475736916397
</code></pre><h3 id="&#x603B;&#x7ED3;">&#x603B;&#x7ED3;</h3>
<blockquote>
<p>&#x901A;&#x8FC7;&#x4EE5;&#x4E0A;&#x793A;&#x4F8B;&#xFF0C;&#x5927;&#x5BB6;&#x5176;&#x5B9E;&#x80FD;&#x77E5;&#x9053;ST_Distance&#x5176;&#x5B9E;&#x662F;&#x4E00;&#x4E2A;&#x5F88;&#x7B80;&#x5355;&#x5F97;&#x51FD;&#x6570;&#xFF0C;&#x6BD4;&#x8F83;&#x590D;&#x6742;&#x5F97;&#x70B9;&#x5728;&#x4E8E;&#x5750;&#x6807;&#x7CFB;&#x4E0A;&#x3002;&#x5BF9;&#x4E8E;&#x5F00;&#x53D1;&#x4EBA;&#x5458;&#x6765;&#x8BF4;&#x53BB;&#x8BB0;&#x5750;&#x6807;&#x7CFB;&#x5176;&#x5B9E;&#x662F;&#x86EE;&#x56F0;&#x96BE;&#x7684;&#xFF0C;&#x5373;&#x4F7F;&#x4E0A;&#x5B66;&#x7684;&#x65F6;&#x5019;&#x5B66;&#x8FC7;&#xFF0C;&#x4F30;&#x8BA1;&#x4E00;&#x6BB5;&#x65F6;&#x95F4;&#x4E5F;&#x5FD8;&#x5230;&#x722A;&#x54C7;&#x56FD;&#x53BB;&#x4E86;&#x3002;&#x6240;&#x4EE5;&#x6B63;&#x786E;&#x4F7F;&#x7528;&#x8BE5;&#x51FD;&#x6570;&#x7684;&#x59FF;&#x52BF;&#x662F;&#x7B2C;6&#x4E2A;&#x793A;&#x4F8B;&#xFF0C;&#x8FD9;&#x79CD;&#x4F7F;&#x7528;&#x65B9;&#x5F0F;&#x5C4F;&#x853D;&#x4E86;&#x5750;&#x6807;&#x7CFB;&#x7684;&#x95EE;&#x9898;&#xFF0C;&#x800C;&#x4E14;&#x8BA1;&#x7B97;&#x7ED3;&#x679C;&#x51C6;&#x786E;&#x3002;&#x5F53;&#x7136;&#x4E5F;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x7B2C;3&#x4E2A;&#x793A;&#x4F8B;&#x7684;&#x65B9;&#x6CD5;&#xFF0C;&#x8FD9;&#x4E2A;&#x793A;&#x4F8B;&#x4F1A;&#x6839;&#x636E;&#x4F60;&#x6240;&#x5728;&#x7684;&#x6295;&#x5F71;&#x5206;&#x5E26;&#xFF0C;&#x8FDB;&#x884C;&#x7ED3;&#x679C;&#x77EB;&#x6B63;&#xFF0C;&#x4F46;&#x662F;&#x8BF4;&#x5B9E;&#x8BDD;&#xFF0C;&#x672C;&#x4EBA;&#x662F;&#x4E0D;&#x77E5;&#x9053;&#x91CC;&#x9762;&#x7684;&#x6570;&#x5B66;&#x903B;&#x8F91;&#x7684;&#x3002;</p>
</blockquote>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="ST_ClosestPoint.html" class="navigation navigation-prev " aria-label="Previous page: ST_ClosestPoint">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="ST_Project.html" class="navigation navigation-next " aria-label="Next page: ST_Project">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"ST_Distance","level":"2.1.4.7","depth":3,"next":{"title":"ST_Project","level":"2.1.4.8","depth":3,"path":"vector_function/Measurement/ST_Project.md","ref":"vector_function/Measurement/ST_Project.md","articles":[]},"previous":{"title":"ST_ClosestPoint","level":"2.1.4.6","depth":3,"path":"vector_function/Measurement/ST_ClosestPoint.md","ref":"vector_function/Measurement/ST_ClosestPoint.md","articles":[]},"dir":"ltr"},"config":{"plugins":["pageview-count","prism","-highlight","custom-favicon","-sharing","emphasize","-lunr","-search","search-pro","graph","splitter","hide-element","folding-chapters"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"prism":{"css":["prismjs/themes/prism-okaidia.css"]},"emphasize":{},"splitter":{},"search-pro":{},"graph":{},"hide-element":{"elements":[".gitbook-link"]},"fontsettings":{"theme":"white","family":"sans","size":2},"folding-chapters":{},"favicon":"../gitbook/images/favicon.ico","pageview-count":{},"custom-favicon":{},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","author":"xxx","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{"service":"http://localhost:4000"},"title":"PostGIS中文指南","gitbook":"*","description":"记录PostGIS使用入门，进阶，提高，附带API全解析"},"file":{"path":"vector_function/Measurement/ST_Distance.md","mtime":"2024-07-23T08:43:00.322Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2024-07-23T09:36:52.257Z"},"basePath":"../..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../../gitbook/gitbook.js"></script>
    <script src="../../gitbook/theme.js"></script>
    
        
        <script src="../../gitbook/gitbook-plugin-pageview-count/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search-pro/jquery.mark.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search-pro/search.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-hide-element/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-folding-chapters/folding-chapters.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

